package com.ruoyi.environment.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.environment.mapper.OpmEnvFacilityMapper;
import com.ruoyi.environment.domain.OpmEnvFacility;
import com.ruoyi.environment.service.IOpmEnvFacilityService;

/**
 * 园区设施Service业务层处理
 *
 * @author cjie
 * @date 2021-07-23
 */
@Service
public class OpmEnvFacilityServiceImpl implements IOpmEnvFacilityService {
    @Autowired
    private OpmEnvFacilityMapper opmEnvFacilityMapper;

    /**
     * 查询园区设施
     *
     * @param id 园区设施ID
     * @return 园区设施
     */
    @Override
    public OpmEnvFacility selectOpmEnvFacilityById(Long id) {
        return opmEnvFacilityMapper.selectOpmEnvFacilityById(id);
    }

    /**
     * 查询园区设施列表
     *
     * @param opmEnvFacility 园区设施
     * @return 园区设施
     */
    @Override
    public List<OpmEnvFacility> selectOpmEnvFacilityList(OpmEnvFacility opmEnvFacility) {
        return opmEnvFacilityMapper.selectOpmEnvFacilityList(opmEnvFacility);
    }

    /**
     * 新增园区设施
     *
     * @param opmEnvFacility 园区设施
     * @return 结果
     */
    @Override
    public int insertOpmEnvFacility(OpmEnvFacility opmEnvFacility) {
        opmEnvFacility.setId(IdUtil.getSnowflake(0, 0).nextId());
        opmEnvFacility.setCreateTime(DateUtils.getNowDate());
        opmEnvFacility.setCreateBy(SecurityUtils.getUsername());
        return opmEnvFacilityMapper.insertOpmEnvFacility(opmEnvFacility);
    }

    /**
     * 修改园区设施
     *
     * @param opmEnvFacility 园区设施
     * @return 结果
     */
    @Override
    public int updateOpmEnvFacility(OpmEnvFacility opmEnvFacility) {
        opmEnvFacility.setUpdateTime(DateUtils.getNowDate());
        opmEnvFacility.setUpdateBy(SecurityUtils.getUsername());
        return opmEnvFacilityMapper.updateOpmEnvFacility(opmEnvFacility);
    }

    /**
     * 批量删除园区设施
     *
     * @param ids 需要删除的园区设施ID
     * @return 结果
     */
    @Override
    public int deleteOpmEnvFacilityByIds(Long[] ids) {
        return opmEnvFacilityMapper.deleteOpmEnvFacilityByIds(ids);
    }

    /**
     * 删除园区设施信息
     *
     * @param id 园区设施ID
     * @return 结果
     */
    @Override
    public int deleteOpmEnvFacilityById(Long id) {
        return opmEnvFacilityMapper.deleteOpmEnvFacilityById(id);
    }
}
